package tgc.rj.garbage;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import org.litepal.LitePal;

import tgc.rj.garbage.activity.TestActivity;
import tgc.rj.garbage.custom.IMainView;
import tgc.rj.garbage.custom.MainPresenter;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, IMainView {

    //private Banner mbanner;
    private TextView btn1, btn2,btn3;
    private TextView shijian, login;
    private ImageView img1;
    private MainPresenter mPresenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        LitePal.getDatabase();
        btn1 = findViewById(R.id.btn1);
        btn2 = findViewById(R.id.btn2);
        btn3 = findViewById(R.id.btn3);
        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
        btn3.setOnClickListener(this);
        login = findViewById(R.id.login);
        login.setOnClickListener(this);
        //屏幕保护
        mPresenter = new MainPresenter(this);


    }


    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.btn1:
                intent = new Intent(this, CanyuActivity.class);
                startActivity(intent);
                break;
            case R.id.btn2:
                intent = new Intent(this, TestActivity.class);
                startActivity(intent);
                break;case R.id.btn3:
                intent = new Intent(this, QitaActivity.class);
                startActivity(intent);
                break;
            case R.id.login:
                intent = new Intent(this, LoginActivity.class);
                startActivity(intent);
                break;
        }
    }



    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        mPresenter.resetTipsTimer();
        return true;
    }

    @Override
    protected void onResume()
    {
        mPresenter.startTipsTimer();
        super.onResume();
    }

    @Override
    protected void onPause()
    {
        mPresenter.endTipsTimer();
        super.onPause();
    }

    @Override
    public void showTipsView() {
        Intent intent = new Intent(MainActivity.this, PmbhActivity.class);
        startActivity(intent);
    }

}